package com.hotel.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import com.hotel.entity.Dishes;
import com.hotel.service.DishesService;

@Controller
public class DishesController {
	@Autowired
	private DishesService dishesService;
	
	@RequestMapping(value="dishesList")
	public ModelAndView findAllDishesList(HttpServletRequest request,@RequestParam(value="pageNo",defaultValue="1")Integer pageNo,@RequestParam(value="pageSize",defaultValue="10")Integer pageSize){
		ModelAndView view1 = new ModelAndView();
		List<Dishes> dishes = dishesService.findAllDishes(pageNo, pageSize);
		view1.addObject("dishes",dishes);
		view1.addObject("pageNo",pageNo);
		view1.addObject("pageSize", pageSize);
		view1.setViewName("views/dishes/dishesList");
		return view1;
	}
	
	@RequestMapping(value="dishesCheckOut")
	public ModelAndView dishesCheckOut(HttpServletRequest request,@RequestParam(value="pageNo",defaultValue="1")Integer pageNo,@RequestParam(value="pageSize",defaultValue="10")Integer pageSize){
		ModelAndView view1 = new ModelAndView();
		//List<Dishes> dishes = dishesService.findAllDishes(pageNo, pageSize);
		//view1.addObject("dishes",dishes);
		view1.addObject("pageNo",pageNo);
		view1.addObject("pageSize", pageSize);
		view1.setViewName("views/dishes/dishescheckout");
		return view1;
	}

}
